package com.wuchao.mapper;

import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.Repository;

import java.util.List;

/**
 * @Author wuchao66
 * @Date 2023/1/6 14:59
 * @PackageName:com.wuchao.mapper
 * @ClassName: T154
 * @Description: TODO
 * @Param
 * @Version 1.0
 */
public interface T154 extends Repository<SysUsers1,Integer> {
        //方法名就是所有你要写的东西
        List<SysUsers1> findSysUsers1ByNameAndAddr(String name,String addr);
//        findSysUsers1ByNameAndAddr
//        select  * from users1 where name=#{name} and addr=#{addr}
        //List<SysUsers1> getSysUsers1sByIdBetweenOrAddr();没写完，教你写
        //只有查。。。拿我我要自定义
        //通过最大的id找到对应的集合
        //注解版 hql --子查询
        @Query("select s from SysUsers1 s where s.id=(select max(id) from SysUsers1)")
        List<SysUsers1>  findSysUsers1ByMaxId();
        //站位？
        @Query("select s from SysUsers1 s where s.id=?1")
        List<SysUsers1>  findSysUsers1ById(Integer id);
        //站位：
        @Query("select s from SysUsers1 s where s.name=:name")
        List<SysUsers1>  findSysUsers1ByName(String name);
        //模糊
        @Query("select s from SysUsers1 s where s.name like %?1%")
        List<SysUsers1>  findSysUsers1ByNameConcat(String name);
        //原生态sql 回去 可以写你以前的sql 要注意原生的sql
        @Query(value="select * from sys_users1  where id=(select max(id) from sys_users1)",
                nativeQuery = true)
        List<SysUsers1>  findSysUsers1ByMaxIdBySql();

        //增删改
        //多表联查注解版--注解都要改成双表--能--  associate 1对多  collection 多对多
        //curd -jpa
        //分页 有问题百度自己解决，我这边没有问题，帮你解决，跟我写你还有问题  mybatis mp mongodb 缓存
        //单表完成一个jpa+springboot内侧



}
